package org.jivesoftware.smack.proxy;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.SocketFactory;

public class Socks4ProxySocketFactory extends SocketFactory
{
  private ProxyInfo proxy;

  public Socks4ProxySocketFactory(ProxyInfo paramProxyInfo)
  {
    this.proxy = paramProxyInfo;
  }

  // ERROR //
  private Socket socks4ProxifiedSocket(String paramString, int paramInt)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_3
    //   2: aload_0
    //   3: getfield 13	org/jivesoftware/smack/proxy/Socks4ProxySocketFactory:proxy	Lorg/jivesoftware/smack/proxy/ProxyInfo;
    //   6: invokevirtual 29	org/jivesoftware/smack/proxy/ProxyInfo:getProxyAddress	()Ljava/lang/String;
    //   9: astore 4
    //   11: aload_0
    //   12: getfield 13	org/jivesoftware/smack/proxy/Socks4ProxySocketFactory:proxy	Lorg/jivesoftware/smack/proxy/ProxyInfo;
    //   15: invokevirtual 33	org/jivesoftware/smack/proxy/ProxyInfo:getProxyPort	()I
    //   18: istore 5
    //   20: aload_0
    //   21: getfield 13	org/jivesoftware/smack/proxy/Socks4ProxySocketFactory:proxy	Lorg/jivesoftware/smack/proxy/ProxyInfo;
    //   24: invokevirtual 36	org/jivesoftware/smack/proxy/ProxyInfo:getProxyUsername	()Ljava/lang/String;
    //   27: astore 6
    //   29: aload_0
    //   30: getfield 13	org/jivesoftware/smack/proxy/Socks4ProxySocketFactory:proxy	Lorg/jivesoftware/smack/proxy/ProxyInfo;
    //   33: invokevirtual 39	org/jivesoftware/smack/proxy/ProxyInfo:getProxyPassword	()Ljava/lang/String;
    //   36: pop
    //   37: new 41	java/net/Socket
    //   40: dup
    //   41: aload 4
    //   43: iload 5
    //   45: invokespecial 44	java/net/Socket:<init>	(Ljava/lang/String;I)V
    //   48: astore 8
    //   50: aload 8
    //   52: invokevirtual 48	java/net/Socket:getInputStream	()Ljava/io/InputStream;
    //   55: astore 14
    //   57: aload 8
    //   59: invokevirtual 52	java/net/Socket:getOutputStream	()Ljava/io/OutputStream;
    //   62: astore 15
    //   64: aload 8
    //   66: iconst_1
    //   67: invokevirtual 56	java/net/Socket:setTcpNoDelay	(Z)V
    //   70: sipush 1024
    //   73: newarray byte
    //   75: astore 16
    //   77: iconst_0
    //   78: iconst_1
    //   79: iadd
    //   80: istore 17
    //   82: aload 16
    //   84: iconst_0
    //   85: iconst_4
    //   86: bastore
    //   87: iload 17
    //   89: iconst_1
    //   90: iadd
    //   91: istore 18
    //   93: aload 16
    //   95: iload 17
    //   97: iconst_1
    //   98: bastore
    //   99: iload 18
    //   101: iconst_1
    //   102: iadd
    //   103: istore 19
    //   105: aload 16
    //   107: iload 18
    //   109: iload_2
    //   110: bipush 8
    //   112: iushr
    //   113: i2b
    //   114: bastore
    //   115: iload 19
    //   117: iconst_1
    //   118: iadd
    //   119: istore 20
    //   121: aload 16
    //   123: iload 19
    //   125: iload_2
    //   126: sipush 255
    //   129: iand
    //   130: i2b
    //   131: bastore
    //   132: aload_1
    //   133: invokestatic 62	java/net/InetAddress:getByName	(Ljava/lang/String;)Ljava/net/InetAddress;
    //   136: invokevirtual 66	java/net/InetAddress:getAddress	()[B
    //   139: astore 24
    //   141: iconst_0
    //   142: istore 25
    //   144: iload 20
    //   146: istore 26
    //   148: aload 24
    //   150: arraylength
    //   151: istore 29
    //   153: iload 25
    //   155: iload 29
    //   157: if_icmplt +122 -> 279
    //   160: aload 6
    //   162: ifnull +39 -> 201
    //   165: aload 6
    //   167: invokevirtual 71	java/lang/String:getBytes	()[B
    //   170: astore 40
    //   172: aload 6
    //   174: invokevirtual 74	java/lang/String:length	()I
    //   177: istore 41
    //   179: aload 40
    //   181: iconst_0
    //   182: aload 16
    //   184: iload 26
    //   186: iload 41
    //   188: invokestatic 80	java/lang/System:arraycopy	(Ljava/lang/Object;ILjava/lang/Object;II)V
    //   191: iload 26
    //   193: aload 6
    //   195: invokevirtual 74	java/lang/String:length	()I
    //   198: iadd
    //   199: istore 26
    //   201: iload 26
    //   203: iconst_1
    //   204: iadd
    //   205: istore 31
    //   207: aload 16
    //   209: iload 26
    //   211: iconst_0
    //   212: bastore
    //   213: aload 15
    //   215: aload 16
    //   217: iconst_0
    //   218: iload 31
    //   220: invokevirtual 86	java/io/OutputStream:write	([BII)V
    //   223: iconst_0
    //   224: istore 32
    //   226: iload 32
    //   228: bipush 6
    //   230: if_icmplt +136 -> 366
    //   233: aload 16
    //   235: iconst_0
    //   236: baload
    //   237: ifeq +167 -> 404
    //   240: new 88	org/jivesoftware/smack/proxy/ProxyException
    //   243: dup
    //   244: getstatic 94	org/jivesoftware/smack/proxy/ProxyInfo$ProxyType:SOCKS4	Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;
    //   247: new 96	java/lang/StringBuilder
    //   250: dup
    //   251: ldc 98
    //   253: invokespecial 101	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   256: aload 16
    //   258: iconst_0
    //   259: baload
    //   260: invokevirtual 105	java/lang/StringBuilder:append	(I)Ljava/lang/StringBuilder;
    //   263: invokevirtual 108	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   266: invokespecial 111	org/jivesoftware/smack/proxy/ProxyException:<init>	(Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;Ljava/lang/String;)V
    //   269: athrow
    //   270: astore 12
    //   272: aload 12
    //   274: astore 13
    //   276: aload 13
    //   278: athrow
    //   279: iload 26
    //   281: iconst_1
    //   282: iadd
    //   283: istore 30
    //   285: aload 16
    //   287: iload 26
    //   289: aload 24
    //   291: iload 25
    //   293: baload
    //   294: bastore
    //   295: iinc 25 1
    //   298: iload 30
    //   300: istore 26
    //   302: goto -154 -> 148
    //   305: astore 21
    //   307: aload 21
    //   309: astore 22
    //   311: new 88	org/jivesoftware/smack/proxy/ProxyException
    //   314: dup
    //   315: getstatic 94	org/jivesoftware/smack/proxy/ProxyInfo$ProxyType:SOCKS4	Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;
    //   318: aload 22
    //   320: invokevirtual 112	java/net/UnknownHostException:toString	()Ljava/lang/String;
    //   323: aload 22
    //   325: invokespecial 115	org/jivesoftware/smack/proxy/ProxyException:<init>	(Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   328: astore 23
    //   330: aload 23
    //   332: athrow
    //   333: astore 9
    //   335: aload 9
    //   337: astore 10
    //   339: aload 8
    //   341: astore_3
    //   342: aload_3
    //   343: ifnull +7 -> 350
    //   346: aload_3
    //   347: invokevirtual 118	java/net/Socket:close	()V
    //   350: new 88	org/jivesoftware/smack/proxy/ProxyException
    //   353: dup
    //   354: getstatic 94	org/jivesoftware/smack/proxy/ProxyInfo$ProxyType:SOCKS4	Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;
    //   357: aload 10
    //   359: invokevirtual 119	java/lang/Exception:toString	()Ljava/lang/String;
    //   362: invokespecial 111	org/jivesoftware/smack/proxy/ProxyException:<init>	(Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;Ljava/lang/String;)V
    //   365: athrow
    //   366: bipush 6
    //   368: iload 32
    //   370: isub
    //   371: istore 33
    //   373: aload 14
    //   375: aload 16
    //   377: iload 32
    //   379: iload 33
    //   381: invokevirtual 125	java/io/InputStream:read	([BII)I
    //   384: istore 34
    //   386: iload 34
    //   388: ifgt +126 -> 514
    //   391: new 88	org/jivesoftware/smack/proxy/ProxyException
    //   394: dup
    //   395: getstatic 94	org/jivesoftware/smack/proxy/ProxyInfo$ProxyType:SOCKS4	Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;
    //   398: ldc 127
    //   400: invokespecial 111	org/jivesoftware/smack/proxy/ProxyException:<init>	(Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;Ljava/lang/String;)V
    //   403: athrow
    //   404: aload 16
    //   406: iconst_1
    //   407: baload
    //   408: istore 35
    //   410: iload 35
    //   412: bipush 90
    //   414: if_icmpeq +46 -> 460
    //   417: aload 8
    //   419: invokevirtual 118	java/net/Socket:close	()V
    //   422: new 96	java/lang/StringBuilder
    //   425: dup
    //   426: ldc 129
    //   428: invokespecial 101	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   431: aload 16
    //   433: iconst_1
    //   434: baload
    //   435: invokevirtual 105	java/lang/StringBuilder:append	(I)Ljava/lang/StringBuilder;
    //   438: invokevirtual 108	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   441: astore 38
    //   443: new 88	org/jivesoftware/smack/proxy/ProxyException
    //   446: dup
    //   447: getstatic 94	org/jivesoftware/smack/proxy/ProxyInfo$ProxyType:SOCKS4	Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;
    //   450: aload 38
    //   452: invokespecial 111	org/jivesoftware/smack/proxy/ProxyException:<init>	(Lorg/jivesoftware/smack/proxy/ProxyInfo$ProxyType;Ljava/lang/String;)V
    //   455: astore 39
    //   457: aload 39
    //   459: athrow
    //   460: aload 14
    //   462: iconst_2
    //   463: newarray byte
    //   465: iconst_0
    //   466: iconst_2
    //   467: invokevirtual 125	java/io/InputStream:read	([BII)I
    //   470: pop
    //   471: aload 8
    //   473: areturn
    //   474: astore 37
    //   476: goto -54 -> 422
    //   479: astore 11
    //   481: goto -131 -> 350
    //   484: astore 43
    //   486: aload 43
    //   488: astore 10
    //   490: goto -148 -> 342
    //   493: astore 42
    //   495: aload 42
    //   497: astore 13
    //   499: goto -223 -> 276
    //   502: astore 27
    //   504: aload 27
    //   506: astore 22
    //   508: iload 26
    //   510: pop
    //   511: goto -200 -> 311
    //   514: iload 32
    //   516: iload 34
    //   518: iadd
    //   519: istore 32
    //   521: goto -295 -> 226
    //
    // Exception table:
    //   from	to	target	type
    //   50	132	270	java/lang/RuntimeException
    //   132	141	270	java/lang/RuntimeException
    //   148	153	270	java/lang/RuntimeException
    //   165	270	270	java/lang/RuntimeException
    //   285	295	270	java/lang/RuntimeException
    //   311	333	270	java/lang/RuntimeException
    //   373	410	270	java/lang/RuntimeException
    //   417	422	270	java/lang/RuntimeException
    //   422	471	270	java/lang/RuntimeException
    //   132	141	305	java/net/UnknownHostException
    //   285	295	305	java/net/UnknownHostException
    //   50	132	333	java/lang/Exception
    //   132	141	333	java/lang/Exception
    //   148	153	333	java/lang/Exception
    //   165	270	333	java/lang/Exception
    //   285	295	333	java/lang/Exception
    //   311	333	333	java/lang/Exception
    //   373	410	333	java/lang/Exception
    //   422	471	333	java/lang/Exception
    //   417	422	474	java/lang/Exception
    //   346	350	479	java/lang/Exception
    //   37	50	484	java/lang/Exception
    //   37	50	493	java/lang/RuntimeException
    //   148	153	502	java/net/UnknownHostException
  }

  public Socket createSocket(String paramString, int paramInt)
    throws IOException, UnknownHostException
  {
    return socks4ProxifiedSocket(paramString, paramInt);
  }

  public Socket createSocket(String paramString, int paramInt1, InetAddress paramInetAddress, int paramInt2)
    throws IOException, UnknownHostException
  {
    return socks4ProxifiedSocket(paramString, paramInt1);
  }

  public Socket createSocket(InetAddress paramInetAddress, int paramInt)
    throws IOException
  {
    return socks4ProxifiedSocket(paramInetAddress.getHostAddress(), paramInt);
  }

  public Socket createSocket(InetAddress paramInetAddress1, int paramInt1, InetAddress paramInetAddress2, int paramInt2)
    throws IOException
  {
    return socks4ProxifiedSocket(paramInetAddress1.getHostAddress(), paramInt1);
  }
}